home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 November: Tool Chest / Dev.CD Nov 98 TC.toast / Sample Code / Snippets / Devices / ModifyMouseAccl / CursorDevices.Glue.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-25  |  9.5 KB  |  304 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        CursorDevices.Glue.c
  3.  
  4.      Copyright:    © 1984-1996 by Apple Computer, Inc.
  5.                  All rights reserved.
  6. */
  7.  
  8. #include <MixedMode.h>
  9. #include <CursorDevices.h>
  10.  
  11. #define RESULT_OFFSET(type) ((sizeof(type) == 1) ? 3 : ((sizeof(type) == 2) ? 1 : 0))
  12.  
  13.  
  14. pascal OSErr CursorDeviceMove(CursorDevicePtr ourDevice, long deltaX, long deltaY)
  15. {
  16.     #ifdef applec
  17.         #if sizeof(OSErr) > 4
  18.             #error "Result types larger than 4 bytes are not supported."
  19.         #endif
  20.     #endif
  21.     long    private_result;
  22.  
  23.     private_result = CallUniversalProc((UniversalProcPtr)NGetTrapAddress(0xAADB, 1),
  24.         kD0DispatchedPascalStackBased
  25.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  26.          | DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kFourByteCode)
  27.          | DISPATCHED_STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ourDevice)))
  28.          | DISPATCHED_STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(deltaX)))
  29.          | DISPATCHED_STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(deltaY))),
  30.         0x00000000,
  31.         ourDevice,
  32.         deltaX,
  33.         deltaY);
  34.     return *(((OSErr*)&private_result) + RESULT_OFFSET(OSErr));
  35. }
  36.  
  37. pascal OSErr CursorDeviceMoveTo(CursorDevicePtr ourDevice, long absX, long absY)
  38. {
  39.     #ifdef applec
  40.         #if sizeof(OSErr) > 4
  41.             #error "Result types larger than 4 bytes are not supported."
  42.         #endif
  43.     #endif
  44.     long    private_result;
  45.  
  46.     private_result = CallUniversalProc((UniversalProcPtr)NGetTrapAddress(0xAADB, 1),
  47.         kD0DispatchedPascalStackBased
  48.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  49.          | DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kFourByteCode)
  50.          | DISPATCHED_STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ourDevice)))
  51.          | DISPATCHED_STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(absX)))
  52.          | DISPATCHED_STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(absY))),
  53.         0x00000001,
  54.         ourDevice,
  55.         absX,
  56.         absY);
  57.     return *(((OSErr*)&private_result) + RESULT_OFFSET(OSErr));
  58. }
  59.  
  60. pascal OSErr CursorDeviceFlush(CursorDevicePtr ourDevice)
  61. {
  62.     #ifdef applec
  63.         #if sizeof(OSErr) > 4
  64.             #error "Result types larger than 4 bytes are not supported."
  65.         #endif
  66.     #endif
  67.     long    private_result;
  68.  
  69.     private_result = CallUniversalProc((UniversalProcPtr)NGetTrapAddress(0xAADB, 1),
  70.         kD0DispatchedPascalStackBased
  71.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  72.          | DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kFourByteCode)
  73.          | DISPATCHED_STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ourDevice))),
  74.         0x00000002,
  75.         ourDevice);
  76.     return *(((OSErr*)&private_result) + RESULT_OFFSET(OSErr));
  77. }
  78.  
  79. pascal OSErr CursorDeviceButtons(CursorDevicePtr ourDevice, short buttons)
  80. {
  81.     #ifdef applec
  82.         #if sizeof(OSErr) > 4
  83.             #error "Result types larger than 4 bytes are not supported."
  84.         #endif
  85.     #endif
  86.     long    private_result;
  87.  
  88.     private_result = CallUniversalProc((UniversalProcPtr)NGetTrapAddress(0xAADB, 1),
  89.         kD0DispatchedPascalStackBased
  90.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  91.          | DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kFourByteCode)
  92.          | DISPATCHED_STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ourDevice)))
  93.          | DISPATCHED_STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(buttons))),
  94.         0x00000003,
  95.         ourDevice,
  96.         buttons);
  97.     return *(((OSErr*)&private_result) + RESULT_OFFSET(OSErr));
  98. }
  99.  
  100. pascal OSErr CursorDeviceButtonDown(CursorDevicePtr ourDevice)
  101. {
  102.     #ifdef applec
  103.         #if sizeof(OSErr) > 4
  104.             #error "Result types larger than 4 bytes are not supported."
  105.         #endif
  106.     #endif
  107.     long    private_result;
  108.  
  109.     private_result = CallUniversalProc((UniversalProcPtr)NGetTrapAddress(0xAADB, 1),
  110.         kD0DispatchedPascalStackBased
  111.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  112.          | DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kFourByteCode)
  113.          | DISPATCHED_STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ourDevice))),
  114.         0x00000004,
  115.         ourDevice);
  116.     return *(((OSErr*)&private_result) + RESULT_OFFSET(OSErr));
  117. }
  118.  
  119. pascal OSErr CursorDeviceButtonUp(CursorDevicePtr ourDevice)
  120. {
  121.     #ifdef applec
  122.         #if sizeof(OSErr) > 4
  123.             #error "Result types larger than 4 bytes are not supported."
  124.         #endif
  125.     #endif
  126.     long    private_result;
  127.  
  128.     private_result = CallUniversalProc((UniversalProcPtr)NGetTrapAddress(0xAADB, 1),
  129.         kD0DispatchedPascalStackBased
  130.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  131.          | DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kFourByteCode)
  132.          | DISPATCHED_STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ourDevice))),
  133.         0x00000005,
  134.         ourDevice);
  135.     return *(((OSErr*)&private_result) + RESULT_OFFSET(OSErr));
  136. }
  137.  
  138. pascal OSErr CursorDeviceButtonOp(CursorDevicePtr ourDevice, short buttonNumber, ButtonOpcode opcode, long data)
  139. {
  140.     #ifdef applec
  141.         #if sizeof(OSErr) > 4
  142.             #error "Result types larger than 4 bytes are not supported."
  143.         #endif
  144.     #endif
  145.     long    private_result;
  146.  
  147.     private_result = CallUniversalProc((UniversalProcPtr)NGetTrapAddress(0xAADB, 1),
  148.         kD0DispatchedPascalStackBased
  149.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  150.          | DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kFourByteCode)
  151.          | DISPATCHED_STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ourDevice)))
  152.          | DISPATCHED_STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(buttonNumber)))
  153.          | DISPATCHED_STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(opcode)))
  154.          | DISPATCHED_STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(data))),
  155.         0x00000006,
  156.         ourDevice,
  157.         buttonNumber,
  158.         opcode,
  159.         data);
  160.     return *(((OSErr*)&private_result) + RESULT_OFFSET(OSErr));
  161. }
  162.  
  163. pascal OSErr CursorDeviceSetButtons(CursorDevicePtr ourDevice, short numberOfButtons)
  164. {
  165.     #ifdef applec
  166.         #if sizeof(OSErr) > 4
  167.             #error "Result types larger than 4 bytes are not supported."
  168.         #endif
  169.     #endif
  170.     long    private_result;
  171.  
  172.     private_result = CallUniversalProc((UniversalProcPtr)NGetTrapAddress(0xAADB, 1),
  173.         kD0DispatchedPascalStackBased
  174.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  175.          | DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kFourByteCode)
  176.          | DISPATCHED_STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ourDevice)))
  177.          | DISPATCHED_STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(numberOfButtons))),
  178.         0x00000007,
  179.         ourDevice,
  180.         numberOfButtons);
  181.     return *(((OSErr*)&private_result) + RESULT_OFFSET(OSErr));
  182. }
  183.  
  184. pascal OSErr CursorDeviceSetAcceleration(CursorDevicePtr ourDevice, Fixed acceleration)
  185. {
  186.     #ifdef applec
  187.         #if sizeof(OSErr) > 4
  188.             #error "Result types larger than 4 bytes are not supported."
  189.         #endif
  190.     #endif
  191.     long    private_result;
  192.  
  193.     private_result = CallUniversalProc((UniversalProcPtr)NGetTrapAddress(0xAADB, 1),
  194.         kD0DispatchedPascalStackBased
  195.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  196.          | DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kFourByteCode)
  197.          | DISPATCHED_STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ourDevice)))
  198.          | DISPATCHED_STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(acceleration))),
  199.         0x00000008,
  200.         ourDevice,
  201.         acceleration);
  202.     return *(((OSErr*)&private_result) + RESULT_OFFSET(OSErr));
  203. }
  204.  
  205. pascal OSErr CursorDeviceDoubleTime(CursorDevicePtr ourDevice, long durationTicks)
  206. {
  207.     #ifdef applec
  208.         #if sizeof(OSErr) > 4
  209.             #error "Result types larger than 4 bytes are not supported."
  210.         #endif
  211.     #endif
  212.     long    private_result;
  213.  
  214.     private_result = CallUniversalProc((UniversalProcPtr)NGetTrapAddress(0xAADB, 1),
  215.         kD0DispatchedPascalStackBased
  216.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  217.          | DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kFourByteCode)
  218.          | DISPATCHED_STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ourDevice)))
  219.          | DISPATCHED_STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(durationTicks))),
  220.         0x00000009,
  221.         ourDevice,
  222.         durationTicks);
  223.     return *(((OSErr*)&private_result) + RESULT_OFFSET(OSErr));
  224. }
  225.  
  226. pascal OSErr CursorDeviceUnitsPerInch(CursorDevicePtr ourDevice, Fixed resolution)
  227. {
  228.     #ifdef applec
  229.         #if sizeof(OSErr) > 4
  230.             #error "Result types larger than 4 bytes are not supported."
  231.         #endif
  232.     #endif
  233.     long    private_result;
  234.  
  235.     private_result = CallUniversalProc((UniversalProcPtr)NGetTrapAddress(0xAADB, 1),
  236.         kD0DispatchedPascalStackBased
  237.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  238.          | DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kFourByteCode)
  239.          | DISPATCHED_STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ourDevice)))
  240.          | DISPATCHED_STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(resolution))),
  241.         0x0000000A,
  242.         ourDevice,
  243.         resolution);
  244.     return *(((OSErr*)&private_result) + RESULT_OFFSET(OSErr));
  245. }
  246.  
  247. pascal OSErr CursorDeviceNextDevice(CursorDevicePtr *ourDevice)
  248. {
  249.     #ifdef applec
  250.         #if sizeof(OSErr) > 4
  251.             #error "Result types larger than 4 bytes are not supported."
  252.         #endif
  253.     #endif
  254.     long    private_result;
  255.  
  256.     private_result = CallUniversalProc((UniversalProcPtr)NGetTrapAddress(0xAADB, 1),
  257.         kD0DispatchedPascalStackBased
  258.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  259.          | DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kFourByteCode)
  260.          | DISPATCHED_STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ourDevice))),
  261.         0x0000000B,
  262.         ourDevice);
  263.     return *(((OSErr*)&private_result) + RESULT_OFFSET(OSErr));
  264. }
  265.  
  266. pascal OSErr CursorDeviceNewDevice(CursorDevicePtr *ourDevice)
  267. {
  268.     #ifdef applec
  269.         #if sizeof(OSErr) > 4
  270.             #error "Result types larger than 4 bytes are not supported."
  271.         #endif
  272.     #endif
  273.     long    private_result;
  274.  
  275.     private_result = CallUniversalProc((UniversalProcPtr)NGetTrapAddress(0xAADB, 1),
  276.         kD0DispatchedPascalStackBased
  277.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  278.          | DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kFourByteCode)
  279.          | DISPATCHED_STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ourDevice))),
  280.         0x0000000C,
  281.         ourDevice);
  282.     return *(((OSErr*)&private_result) + RESULT_OFFSET(OSErr));
  283. }
  284.  
  285. pascal OSErr CursorDeviceDisposeDevice(CursorDevicePtr ourDevice)
  286. {
  287.     #ifdef applec
  288.         #if sizeof(OSErr) > 4
  289.             #error "Result types larger than 4 bytes are not supported."
  290.         #endif
  291.     #endif
  292.     long    private_result;
  293.  
  294.     private_result = CallUniversalProc((UniversalProcPtr)NGetTrapAddress(0xAADB, 1),
  295.         kD0DispatchedPascalStackBased
  296.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  297.          | DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kFourByteCode)
  298.          | DISPATCHED_STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ourDevice))),
  299.         0x0000000D,
  300.         ourDevice);
  301.     return *(((OSErr*)&private_result) + RESULT_OFFSET(OSErr));
  302. }
  303.  
  304.